import { user, list, banner, chechUser } from "./data"
export default {
    //get请求
    'GET /test': { name: "admin", age: 18, location: "get深圳" },
    // post请求
    'POST /admin/base/open/login': (req, res) => {
        // console.log(req.body)
        const { username, password } = req.body
        if (username == 'admin' && password == '1234') {
            res.send({
                code: 1000,
                message: "success",
                data: {
                    token:
                        "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc1JlZnJlc2giOmZhbHNlLCJ1c2VybmFtZSI6ImFkbWluIiwidXNlcklkIjoxMSwicGFzc3dvcmRWZXJzaW9uIjo4LCJjdXJyZW50Um9sZSI6ImZhbWlseVBhcnR5UmVjb3JkIiwibmFtZSI6ImFkbWluIiwiaWF0IjoxNjU5NDEwOTE3LCJleHAiOjE2NTk0OTczMTd9.DN03tKmHuONKpqXeRlApQkB5tlLm3ZQExHuinLaqCPU",
                    roles: ['userManage', 'activityManage']
                },
            })
        } else {
            res.send({
                code: 1000,
                message: "success",
                data: {
                    token:
                        "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc1JlZnJlc2giOmZhbHNlLCJ1c2VybmFtZSI6ImFkbWluIiwidXNlcklkIjoxMSwicGFzc3dvcmRWZXJzaW9uIjo4LCJjdXJyZW50Um9sZSI6ImZhbWlseVBhcnR5UmVjb3JkIiwibmFtZSI6ImFkbWluIiwiaWF0IjoxNjU5NDEwOTE3LCJleHAiOjE2NTk0OTczMTd9.DN03tKmHuONKpqXeRlApQkB5tlLm3ZQExHuinLaqCPU",
                    roles: ['activityManage']
                },
            })
        }

    },
    'POST /admin/base/activityManage/page': (req, res) => {
        // console.log(req.body)
        const { size, page, activityStatus, activityName } = req.body
        res.send({
            code: 1000,
            message: "success",
            data: {
                list: list,
                pagination: {

                    size, page, total: 1 // 总条数

                }

            }
        })

    },
    'POST /admin/base/activityManage/delete': (req, res) => {
        // console.log(req.body)
        const { ids } = req.body
        ids.forEach(item=>{
            list.forEach((citem, index) => {
                if (ids.includes(citem.id)) {
                    // console.log(citem, index);
                    list.splice(index, 1)
                }
            })
        })
        res.send({
            code: 1000,
            message: "success"
        })

    },
    'POST /admin/base/activityManage/add': (req, res) => {
        // console.log(req.body)
        list.push({ ...req.body, id: list.length + 1, key: list.length + 1 })
        res.send({
            code: 1000,
            message: "success"
        })

    },
    'POST /admin/base/activityManage/update': (req, res) => {
        // console.log(req.body)

        list.forEach(item => {
            if (item.id == req.body.id) {
                item = req.body
            }
        })
        res.send({
            code: 1000,
            message: "success"
        })

    },
    'POST /admin/base/activityManage/info': (req, res) => {
        // console.log(req.body)
        const { id } = req.body
        list.forEach(item => {
            if (item.id == id) {
                res.send({
                    code: 1000,
                    message: "success",
                    data: item
                })
            }
        })


    },
    'POST /admin/base/banner/page': (req, res) => {
        // console.log(req.body)
        const { size, page, activityStatus, activityName } = req.body
        res.send({
            code: 1000,
            message: "success",
            data: {
                list: banner,
                pagination: {

                    size, page, total: 1 // 总条数

                }

            }
        })

    },
    'POST /admin/base/banner/delete': (req, res) => {
        // console.log(req.body)
        const { ids } = req.body
        ids.forEach(item=>{
            banner.forEach((citem, index) => {
                if (ids.includes(citem.id)) {
                    // console.log(citem, index);
                    banner.splice(index, 1)
                }
            })
        })
        res.send({
            code: 1000,
            message: "success"
        })
    },
    'POST /admin/storeManage/cookTeam/add': (req, res) => {
        // console.log(req.body)
        list.push({ ...req.body, id: list.length + 1, key: list.length + 1 })
        res.send({
            code: 1000,
            message: "success"
        })
    },
    'POST /admin/base/user/page': (req, res) => {
        // console.log(req.body)
        
        const {size,page,isback,checking,username}=req.body
        res.send({
            code: 1000,
            message: "success",
            data: {
                list: chechUser,
                pagination: {

                    size, page, total: 1 // 总条数

                }
            }
        })
    },
    'POST /admin/base/user/delete': (req, res) => {
        // console.log(req.body)
        const { ids } = req.body
        ids.forEach(item=>{
            chechUser.forEach((citem, index) => {
                if (ids.includes(citem.id)) {
                    // console.log(citem, index);
                    chechUser.splice(index, 1)
                }
            })
        })
        res.send({
            code: 1000,
            message: "success"
        })
    },
    'POST /admin/base/user/update': (req, res) => {
        // console.log(req.body)
        const { checking,id } = req.body
        chechUser.forEach((item, index) => {
            if (item.id==id) {
                // console.log(item, index);
                item.checking=checking
            }
        })
        res.send({
            code: 1000,
            message: "success"
        })
    },
    'POST /admin/base/user/add': (req, res) => {
        // console.log(req.body)
        chechUser.push({ ...req.body, id: chechUser.length + 1})
        res.send({
            code: 1000,
            message: "success"
        })
    },
    'POST /admin/base/user/info': (req, res) => {
        // console.log(req.body)
        const { id } = req.body
        chechUser.forEach(item => {
            if (item.id == id) {
                res.send({
                    code: 1000,
                    message: "success",
                    data: item
                })
            }
        })


    },


}